
package backupUtility;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;


public class BackupLogic {
    public BackupLogic(ArrayList<File> selected) throws IOException{
    File directory = new File("D:/BACKUP");
    if (!directory.exists()) {
           System.out.println("Creating directory: " +directory.getName());
           boolean result = directory.mkdir();  
            if(result) {    
              System.out.println("DIR created");  
            }
         }
    File copy;
    for(File f : selected){
    copyFileUsingJava7Files(f, new File("D:/Backup"+f.getName()));
    }
    
    }
    private static void copyFileUsingJava7Files(File source, File dest) throws IOException {
    Files.copy(source.toPath(), dest.toPath());
    }
}
